package com.benny_driving_dri.act.adapter;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.benny_driving_dri.R;
import com.benny_driving_dri.entity.UserComment;

public class UserEvaAdapter extends BaseAdapter {
	private LayoutInflater layoutInflater = null;
	private List<UserComment> list = null;

	public UserEvaAdapter(List<UserComment> list, Context context) {
		this.list = list;
		layoutInflater = LayoutInflater.from(context);
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return list.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return list.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder holder = null;
		if (convertView == null) {
			convertView = layoutInflater.inflate(R.layout.adapter_usereva,
					parent, false);
			holder = new ViewHolder();
			holder.phn = (TextView) convertView
					.findViewById(R.id.UserEva_tv_Phn);
			holder.time = (TextView) convertView
					.findViewById(R.id.UserEva_tv_Time);
			holder.con = (TextView) convertView
					.findViewById(R.id.UserEva_tv_Con);

			holder.phn.setText(list.get(position).getTel());
			holder.time.setText(list.get(position).getTime());
			holder.con.setText(list.get(position).getContent());

			convertView.setTag(holder);
		} else {
			holder = (ViewHolder) convertView.getTag();
		}
		return convertView;
	}

	class ViewHolder {
		TextView phn, time, con;
	}

}
